# -*-  coding:utf-8 -*- 
# Author : lihongliang

product_list = [["iphone",4688],["mac",8999],["小米手机",1999],["锤子手机",1000]]

shopping_car = []
shopping_total = 0
salary = int(input("请输入薪资："))

while True:
    for i in product_list:
        print(product_list.index(i),i[0],i[1])

    choice = input("请输入你要购买的商品代码或者输入Q/q退出：")
    if choice.isdigit():
        choice = int(choice)
        if choice >=0 and choice < len(product_list):
            shopping_car.append(product_list[choice])
            shopping_total += product_list[choice][1]
            if salary - shopping_total < 0:
                print("余额不足")
            print("购物车商品：%s" % shopping_car)
    elif choice == "Q" or choice == "q":
        break
    else:
        print("请输入正确的商品代码或者退出！")
print("你总共购买商品：%s,消费%s, 剩余%s"%(shopping_car,shopping_total,(salary-shopping_total)))